<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>教务系统后台管理</title>
<link rel="stylesheet" href="../static/layui/css/layui.css"
	th:href="${'layui/css/layui.css'}">
<script type="text/javascript" src="layui/layui.js"></script>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body class="layui-layout-body">
	<div class="layui-layout layui-layout-admin">
		<div class="layui-header">
			<div class="layui-logo">教务平台</div>
			<!-- 头部区域（可配合layui已有的水平导航） -->
			<ul class="layui-nav layui-layout-left">
				<li class="layui-nav-item"><a href="student_information"></a></li>
				<li class="layui-nav-item"><a>学生管理</a>
					<dl class="layui-nav-child">
						<dd>
							<a id="select_student_information">学生信息查询</a>
						</dd>
						<dd>
							<a id="student_achievement">学生成绩查询</a>
						</dd>
					</dl></li>

				<li class="layui-nav-item"><a>教师管理</a>
					<dl class="layui-nav-child">
						<dd>
							<a id="teacher_information">教师信息查询</a>
						</dd>
					</dl></li>

				<li class="layui-nav-item"><a>用户管理</a>
					<dl class="layui-nav-child">
						<dd>
							<a id="user_information">用户信息</a>
						</dd>
					</dl></li>

				<li class="layui-nav-item"><a href="evaluate">教学评价</a></li>
			</ul>
			<ul class="layui-nav layui-layout-right">
				<li class="layui-nav-item"><a href="javascript:;"> <img
						th:src="${image}" class="layui-nav-img"> [[${name}]]
				</a>
					<dl class="layui-nav-child">
						<dd>
							<a>基本资料</a>
						</dd>
						<dd>
							<a id="perfect_information">完善个人资料</a>
						</dd>
						<dd>
							<a th:href="change_password">更改密码</a>
						</dd>
					</dl></li>
				<li class="layui-nav-item"><a href="hello">退出</a></li>
			</ul>
		</div>

		<div class="layui-side layui-bg-black">
			<div class="layui-side-scroll">
				<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
				<ul class="layui-nav layui-nav-tree">
					<li class="layui-nav-item"><a>个人信息</a>
						<dl class="layui-nav-child">
							<dd>
								<a id="perfect_information1">完善个人信息</a>
							</dd>
							<dd>
								<a id="change_information">修改个人信息</a>
							</dd>
						</dl></li>
					<li class="layui-nav-item"><a>学生管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a id="select_student_information1">学生信息查询</a>
							</dd>
							<dd>
								<a id="student_achievement1">学生成绩查询</a>
							</dd>
						</dl></li>
					<li class="layui-nav-item"><a>教师管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a id="teacher_information1">教师信息查询</a>
							</dd>
						</dl></li>

					<li class="layui-nav-item"><a>用户管理</a>
						<dl class="layui-nav-child">
							<dd>
								<a id="user_information1">用户信息</a>
							</dd>
						</dl></li>

					<li class="layui-nav-item"><a href="evaluate">教学评价</a></li>
				</ul>
			</div>
		</div>
		
		<script>
			$("#perfect_information,#perfect_information1").click(function() {
				$.ajax({
					url : 'getroot',
					dataType : 'json',
					type : 'post',
					success : function(data) {
						if (data == 0) {
							$("#pshow").toggle();
						} else {
							$("#p1").toggle();
						}
	
					}
				})
			});
			$("#change_information").click(function() {
				$.ajax({
					url : 'root',
					dataType : 'json',
					type : 'post',
					success : function(data) {
						if (data == 0) {
							$("#p2").toggle();
						} else {
							alert("请先完善个人信息");
						}
	
					}
				})
			});
			$("#select_student_information,#select_student_information1").click(function() {
				$("#p3").toggle();
			});
			$("#student_achievement,#student_achievement1").click(function(){
				$("#p4").toggle();
			});
			$("#teacher_information,#teacher_information1").click(function(){
				$("#p5").toggle();
			});
			$("#user_information,#user_information1").click(function(){
				$("#p6").toggle();
			})
		</script>
		<!-- 主体区域 -->
		<div class="layui-body"style="background: url(img/12.jpg); background-repeat: no-repeat; background-size: 100% 100%;">
		
			<div id="p1" hidden="hidden" style="padding: 15px; width: 1000px;">
				<div class="layui-tab" style="margin-left: 0px;">
					<blockquote class="layui-elem-quote">
						<h1>完善个人信息</h1>
					</blockquote>
				</div>
				<form class="layui-form" action="perfectroot">
				
					<div class="layui-form-item">
						<label class="layui-form-label">身份证号</label>
						<div class="layui-input-block">
							<input type="text" name="ID_card" placeholder="请输入身份证号"
								class="layui-input">
							<div class="layui-form-mid layui-word-aux">绑定后不能修改信息</div>
						</div>

					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">手机号</label>
						<div class="layui-input-block">
							<input type="text" name="phone" placeholder="请输入手机号"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">邮箱</label>
						<div class="layui-input-block">
							<input type="text" name="box" placeholder="请输入邮箱"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">名字</label>
						<div class="layui-input-inline">
							<input type="text" name="root_name" placeholder="请输入名字"
								class="layui-input">
							<div class="layui-form-mid layui-word-aux">绑定后不能修改信息</div>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">性别</label>
						<div class="layui-input-block">
							<input type="radio" name="sex" value="男" title="男"> <input
								type="radio" name="sex" value="女" title="女">
						</div>
						<div class="layui-form-mid layui-word-aux">绑定后不能修改信息</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">家庭住址</label>
						<div class="layui-input-block">
							<input type="text" name="home" placeholder="请输入家庭住址"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>

			<!-- 提示个人信息已经完善 -->
			<div id="pshow" hidden="hidden" style="padding: 15px; width: 1000px;">
				<div class="layui-tab" style="margin-left: 0px;">
					<blockquote class="layui-elem-quote">
						<h1>个人信息已经完善</h1>
					</blockquote>
				</div>
			</div>
			
			
			<!--修改个人信息  -->
			<div id="p2" hidden="hidden" style="padding: 15px; width: 1000px;">
				<div class="layui-tab" style="margin-left: 0px;">
					<blockquote class="layui-elem-quote">
						<h1>完善个人信息</h1>
					</blockquote>
				</div>
				<form class="layui-form" action="changeroot">
					<div class="layui-form-item">
						<label class="layui-form-label">手机号</label>
						<div class="layui-input-block">
							<input type="text" name="changephone" placeholder="请输入手机号"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">邮箱</label>
						<div class="layui-input-block">
							<input type="text" name="changebox" placeholder="请输入邮箱"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">家庭住址</label>
						<div class="layui-input-block">
							<input type="text" name="changehome" placeholder="请输入家庭住址"
								class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn">立即提交</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>
			
			<!-- 学生信息查询 -->
			<div id="p3" hidden="hidden" style="padding: 15px; width: 1000px;">
				<div class="layui-tab" style="margin-left: 0px;">
					<blockquote class="layui-elem-quote">
						<h1>学生信息</h1>
					</blockquote>
				</div>
				<div class="demoTable">
					搜索：
					<div class="layui-inline">
						<input class="layui-input" name="name" id="name"
							autocomplete="off" placeholder="学生姓名">
					</div>
					<div class="layui-inline">
						<input class="layui-input" name="account" id="account"
							autocomplete="off" placeholder="学生账号">
					</div>
					<button class="layui-btn" id="search1">搜索</button>
				</div>  
				<table id="student_information" lay-filter="test"></table>
			</div>
			
			<!-- 学生成绩查询 	-->
			<div id="p4" hidden="hidden" style="padding: 15px; width: 1000px;">
				<div class="layui-tab" style="margin-left: 0px;">
					<blockquote class="layui-elem-quote">
						<h1>学生成绩</h1>
					</blockquote>
				</div>
				<div class="demoTable">
					搜索：
					<div class="layui-inline">
						<input class="layui-input" name="name2" id="name2"
							autocomplete="off" placeholder="学生姓名">
					</div>
					<div class="layui-inline">
						<input class="layui-input" name="course_name" id="course_name"
							autocomplete="off" placeholder="课程名">
					</div>
					<button class="layui-btn" id="searchScore">搜索</button>
				</div>  
				<table id="studentAchievement" lay-filter="test"></table>
			</div>
		
			
			<!-- 教师信息查询 -->
			<div id="p5" hidden="hidden" style="padding: 15px; width: 1000px;">
				<div class="layui-tab" style="margin-left: 0px;">
					<blockquote class="layui-elem-quote">
						<h1>教师信息</h1>
					</blockquote>
				</div>
				<div class="demoTable">
					搜索：
					<div class="layui-inline">
						<input class="layui-input" name="teacher_name" id="teacher_name"
							autocomplete="off" placeholder="教师姓名">
					</div>
					<div class="layui-inline">
						<input class="layui-input" name="teacher_account" id="teacher_account"
							autocomplete="off" placeholder="教师账号">
					</div>
					<button class="layui-btn" id="searchteacher">搜索</button>
				</div>  
				<table id="teacherInformation" lay-filter="test"></table>
			</div>
			
			
			<!-- 用户信息查询 -->
			<div id="p6" hidden="hidden" style="padding: 15px; width: 1000px;">
				<div class="layui-tab" style="margin-left: 0px;">
					<blockquote class="layui-elem-quote">
						<h1>用户信息</h1>
					</blockquote>
				</div>
				<div class="layui-btn-group">
				  <button type="button" class="layui-btn layui-btn-primary layui-btn-sm" id="add">
				    <i class="layui-icon">&#xe654;</i>
				  </button>
				</div>  
				<table id="userInformation" lay-filter="test"></table>
			</div>
			
			
		<div class="layui-footer">底部固定区域</div>
		</div>
	</div>
	
	
	<script type="text/javascript" th:inline="none">
			$("#select_student_information,#select_student_information1").click(function() {
				layui.use('table', function() {
					var table = layui.table;
					table.render({
						elem : '#student_information',
						url : 'select_student_information',
						cols : [ [ {
							field : 'student_id',
							width : 100,
							title : '序列号',
							sort : true
						}, {
							field : 'student_name',
							width : 100,
							title : '学生姓名'
						}, {
							field : 'student_sex',
							width : 100,
							title : '学生性别',
						}, {
							field : 'student_IDcard',
							width : 200,
							title : '身份证号',
						},{
							field : 'student_phone',
							width : 150,
							title : '电话',
						},{
							field : 'student_email',
							width : 150,
							title : '电子邮箱',
						},{
							field : 'student_home',
							width : 150,
							title : '家庭住址',
						},{
							field : 'student_number',
							width : 150,
							title : '账号',
						},{
							fixed: 'right', 
					    	width: 150, 
					    	align:'center',
					    	title:'操作',
					    	toolbar: '#bar'}] ],
						page : true,
						width : 1000,
						parseData : function(data) {
							return {
								"code" : 0,
								"msg" : "",
								"count" : data.length,
								"data" : data
							}
						}
					});
				});
			});
		</script>
		
		
		
		<script>
			$("#search1").click(function() {
				var name = document.getElementById("name").value;
				var account = document.getElementById("account").value;
				$.ajax({
					url : 'getStudentByinformation',
					dataType : 'json',
					type : 'post',
					data : {
						"name" : name,
						"account" : account
					},
				});

				layui.use('table', function() {
					var table = layui.table;
					table.render({
						elem : '#student_information',
						url : 'getStudentByNameOrAccount',
						cols : [ [ {
							field : 'student_id',
							width : 100,
							title : '序列号',
							sort : true
						}, {
							field : 'student_name',
							width : 100,
							title : '学生姓名'
						}, {
							field : 'student_sex',
							width : 100,
							title : '学生性别',
						}, {
							field : 'student_IDcard',
							width : 200,
							title : '身份证号',
						},{
							field : 'student_phone',
							width : 150,
							title : '电话',
						},{
							field : 'student_email',
							width : 150,
							title : '电子邮箱',
						},{
							field : 'student_home',
							width : 150,
							title : '家庭住址',
						},{
							field : 'student_number',
							width : 150,
							title : '账号',
						},{
							fixed: 'right', 
						    width: 150, 
						    align:'center',
						    title:'操作',
						    toolbar: '#bar'}] ],
						page : true,
						width : 1000,
						parseData : function(data) {
							return {
								"code" : 0,
								"msg" : "",
								"count" : data.length,
								"data" : data
							}
						}
					});
				});
			});
		</script>
		
		<script type="text/html" id="bar">
 			<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
  			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" id="del">删除</a>
		</script>
		
		<script type="text/javascript">
			layui.use('table', function(){
			  var table = layui.table;
			  //监听工具条
			  table.on('tool(test)', function(obj){
			    var data = obj.data;
			    if(obj.event === 'detail'){
			        layer.msg('ID:'+ data.student_id+'</br>Name:'+ data.student_name + '</br>Sex:' + data.student_sex + '</br>IDcard:'+data.student_IDcard+'</br>Phone:'+data.student_phone +'</br>Email:'+data.student_email+'</br>Home:'+data.student_home+'</br>Number:'+data.student_number);
			      }else if(obj.event === 'del'){
			      layer.confirm('真的删除行么', function(index){
			        obj.del();
			        $.ajax({
						url : 'deleteStudent',
						dataType : 'json',
						type : 'post',
						data : {
							"student_id" : JSON.stringify(data.student_id)
						},
					})
			        layer.close(index);
			      });
			    }
			  });
			  
			});
		</script>
		
		<script type="text/javascript">
			$("#teacher_information,#teacher_information1").click(function(){
				layui.use('table', function() {
					var table = layui.table;
					table.render({
						elem : '#teacherInformation',
						url : 'getTeacherInformation',
						cols : [ [ {
							field : 'teacher_id',
							width : 100,
							title : '序列号',
							sort : true
						}, {
							field : 'teacher_name',
							width : 100,
							title : '教师姓名'
						}, {
							field : 'teacher_sex',
							width : 100,
							title : '教师性别',
						}, {
							field : 'teacher_IDcard',
							width : 200,
							title : '身份证号',
						},{
							field : 'teacher_phone',
							width : 150,
							title : '电话',
						},{
							field : 'teacher_email',
							width : 150,
							title : '电子邮箱',
						},{
							field : 'teacher_home',
							width : 150,
							title : '家庭住址',
						},{
							field : 'teacher_number',
							width : 150,
							title : '账号',
						},{
							fixed: 'right', 
						    width: 150, 
						    align:'center',
						    title:'操作',
						    toolbar: '#Teacherbar'}] ],
						page : true,
						width : 1000,
						parseData : function(data) {
							return {
								"code" : 0,
								"msg" : "",
								"count" : data.length,
								"data" : data
							}
						}
					});
				});
			})
		</script>
		
		<script type="text/html" id="Teacherbar">
 			<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="teacher_detail">查看</a>
  			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" id="teacher_del">删除</a>
		</script>
		
		<script type="text/javascript">
			layui.use('table', function(){
			  var table = layui.table;
			  //监听工具条
			  table.on('tool(test)', function(obj){
			    var data = obj.data;
			    if(obj.event === 'teacher_detail'){
			        layer.msg('ID:'+ data.teacher_id+'</br>Name:'+ data.teacher_name + '</br>Sex:' + data.teacher_sex + '</br>IDcard:'+data.teacher_IDcard+'</br>Phone:'+data.teacher_phone +'</br>Email:'+data.teacher_email+'</br>Home:'+data.teacher_home+'</br>Number:'+data.teacher_number);
			      }else if(obj.event === 'teacher_del'){
			      layer.confirm('真的删除行么', function(index){
			        obj.del();
			        $.ajax({
						url : 'deleteTeacher',
						dataType : 'json',
						type : 'post',
						data : {
							"teacher_id" : JSON.stringify(data.teacher_id)
						},
					})
			        layer.close(index);
			      });
			    }
			  });
			  
			});
		</script>
		
		<script>
			$("#searchteacher").click(function() {
				var name = document.getElementById("teacher_name").value;
				var account = document.getElementById("teacher_account").value;
				$.ajax({
					url : 'getTeacherByinformation',
					dataType : 'json',
					type : 'post',
					data : {
						"teacher_name" : name,
						"teacher_account" : account
					},
				});

				layui.use('table', function() {
					var table = layui.table;
					table.render({
						elem : '#teacherInformation',
						url : 'getTeacherByNameOrAccount',
						cols : [ [ {
							field : 'teacher_id',
							width : 100,
							title : '序列号',
							sort : true
						}, {
							field : 'teacher_name',
							width : 100,
							title : '教师姓名'
						}, {
							field : 'teacher_sex',
							width : 100,
							title : '教师性别',
						}, {
							field : 'teacher_IDcard',
							width : 200,
							title : '身份证号',
						},{
							field : 'teacher_phone',
							width : 150,
							title : '电话',
						},{
							field : 'teacher_email',
							width : 150,
							title : '电子邮箱',
						},{
							field : 'teacher_home',
							width : 150,
							title : '家庭住址',
						},{
							field : 'teacher_number',
							width : 150,
							title : '账号',
						},{
							fixed: 'right', 
						    width: 150, 
						    align:'center',
						    title:'操作',
						    toolbar: '#Teacherbar'}] ],
						page : true,
						width : 1000,
						parseData : function(data) {
							return {
								"code" : 0,
								"msg" : "",
								"count" : data.length,
								"data" : data
							}
						}
					});
				});
			});
		</script>
		
		<script type="text/javascript">
			$("#student_achievement,#student_achievement1").click(function(){
				layui.use('table', function() {
					var table = layui.table;
					table.render({
						elem : '#studentAchievement',
						url : 'getStudentAchievement',
						cols : [ [ {
							field : 'id',
							width : 200,
							title : '序列号',
							sort : true
						}, {
							field : 'student_name',
							width : 200,
							title : '学生姓名'
						}, {
							field : 'course_name',
							width : 200,
							title : '课程名',
						}, {
							field : 'score',
							width : 200,
							title : '分数',
							sort : true
						},] ],
						page : true,
						width : 800,
						parseData : function(data) {
							return {
								"code" : 0,
								"msg" : "",
								"count" : data.length,
								"data" : data
							}
						}
					});
				});
			});
		</script>
		
		<script type="text/javascript">
		$("#searchScore").click(function() {
			var name = document.getElementById("name2").value;
			var account = document.getElementById("course_name").value;
			$.ajax({
				url : 'getScoreByinformation',
				dataType : 'json',
				type : 'post',
				data : {
					"name2" : name,
					"course_name" : account
				},
			});

			layui.use('table', function() {
				var table = layui.table;
				table.render({
					elem : '#studentAchievement',
					url : 'getScoreByName',
					cols : [ [ {
						field : 'id',
						width : 200,
						title : '序列号',
						sort : true
					}, {
						field : 'student_name',
						width : 200,
						title : '学生姓名'
					}, {
						field : 'course_name',
						width : 200,
						title : '课程名',
					}, {
						field : 'score',
						width : 200,
						title : '分数',
						sort : true
					}] ],
					page : true,
					width : 1000,
					parseData : function(data) {
						return {
							"code" : 0,
							"msg" : "",
							"count" : data.length,
							"data" : data
						}
					}
				});
			});
		});
		</script>
		
		<script type="text/javascript">
		$("#user_information,#user_information1").click(function(){
			layui.use('table', function() {
				var table = layui.table;
				table.render({
					elem : '#userInformation',
					url : 'getuserInformation',
					cols : [ [ {
						field : 'user_id',
						width : 200,
						title : '序列号',
						sort : true
					}, {
						field : 'account',
						width : 200,
						title : '账户'
					}, {
						field : 'password',
						width : 200,
						title : '密码',
					}, {
						field : 'power',
						width : 200,
						title : '权限等级',
						sort : true
					},{
						fixed: 'right', 
					    width: 150, 
					    align:'center',
					    title:'操作',
					    toolbar: '#Userbar'}] ],
					page : true,
					width : 800,
					parseData : function(data) {
						return {
							"code" : 0,
							"msg" : "",
							"count" : data.length,
							"data" : data
						}
					}
				});
			});
		});
		</script>
		
		<script type="text/html" id="Userbar">
  			<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="user_del" id="user_del">删除</a>
		</script>
		
		<script type="text/javascript">
			layui.use('table', function(){
			  var table = layui.table;
			  //监听工具条
			  table.on('tool(test)', function(obj){
			    var data = obj.data;
			    if(obj.event === 'user_del'){
			      layer.confirm('真的删除行么', function(index){
			        obj.del();
			        $.ajax({
						url : 'deleteUser',
						dataType : 'json',
						async : false,
						type : 'post',
						data : {
							"user_id" : JSON.stringify(data.user_id)
						},
						success : function(data) {
							if(data==1){
								alert("删除成功")
							}else{
								alert("删除失败，你不能删除此条信息")
							}
						}
					})
			        layer.close(index);
			      });
			      
			    }
			  });
			  
			});
		</script>
		
		
		<script>
			$("#add").click(function(){
	         var index = layer.prompt({
	        	 formType: 0,
	        	  value: '账户',
	        	  closeBtn:0,
	        	  title: '请输入值'
	        	  }, 
	        	function(value, index, elem){
	        	  var a = document.getElementById("zxr").value;
	        	  layer.close(index);
	        	  $.ajax({
						url : 'addUser',
						dataType : 'json',
						async : false,
						type : 'post',
						data : {
							"user_account": value,
							"user_power":a
						},
						success : function(data) {
							if(data==1){
								alert("添加成功")
								layui.use('table', function() {
									var table = layui.table;
									table.render({
										elem : '#userInformation',
										url : 'getuserInformation',
										cols : [ [ {
											field : 'user_id',
											width : 200,
											title : '序列号',
											sort : true
										}, {
											field : 'account',
											width : 200,
											title : '账户'
										}, {
											field : 'password',
											width : 200,
											title : '密码',
										}, {
											field : 'power',
											width : 200,
											title : '权限等级',
											sort : true
										},{
											fixed: 'right', 
										    width: 150, 
										    align:'center',
										    title:'操作',
										    toolbar: '#Userbar'}] ],
										page : true,
										width : 800,
										parseData : function(data) {
											return {
												"code" : 0,
												"msg" : "",
												"count" : data.length,
												"data" : data
											}
										}
									});
								});
							}else{
								alert("添加失败")
							}
						}
					})
	        	 })
	        	$(".layui-layer-content").append("<br/><input type=\"text\" id= \"zxr\" class=\"layui-input\" placeholder=\"权限\"/>");    	
			})
		</script>
</body>
</html>